namespace CodeConsult.Nordic.nRF8001.ApplicationControlInterface.Commands.SystemCommands
{
    public class BondCommand : AciCommandBase
    {
        public const byte OpCode = 0x10;

        public ushort Timeout { get; set; }
        public ushort AdvInterval { get; set; }

        protected override void EncodeBuffer()
        {
            Error = Error || Timeout < 1 || Timeout > 180;
            Error = Error || AdvInterval < 0x0020 || Timeout > 0x4000;

            if (Error) return;

            EncodeBufferWithCommandHeader(OpCode, 4);
            EncodeHelper.SetUnsignedShort(Timeout, EncodeHelper.ByteOrder.LsbMsb);
            EncodeHelper.SetUnsignedShort(AdvInterval, EncodeHelper.ByteOrder.LsbMsb);
        }
    }
}
